package com.zrar.ak.gkpt.jpa;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long> {

    @Query("select u from User u where u.firstName like %?1%")
    List<User> findUsersByFirstName(String firstName);

    @Query(value = "SELECT u FROM User u WHERE u.firstName like %?1%",
//            countQuery = "SELECT count(u) FROM User u WHERE u.lastName like %?1%",
            nativeQuery = false)
    Page<User> findByLastname(String lastname, Pageable pageable);
}
